package com.salton123.groupbargain.ui.adapter

import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter

/**
 * User: newSalton@outlook.com
 * Date: 2020-01-26 20:31
 * ModifyTime: 20:31
 * Description:
 */
class RecommendAdapter(host: Fragment) : FragmentStateAdapter(host) {
    private var mData = mutableListOf<Fragment>()
    open fun setData(fragments: MutableList<Fragment>) {
        mData.clear()
        mData.addAll(fragments)
        notifyDataSetChanged()
    }

    open fun addDataNotify(item: Fragment) {
        mData.add(item)
        notifyDataSetChanged()
    }

    override fun getItemCount(): Int = mData.size

    override fun createFragment(position: Int): Fragment {
        return mData[position]
    }
}